<%@ page language="java" contentType="text/html; charset=UTF-8"
	    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>   
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/lib/bootstrap-3.3.7-dist/css/bootstrap.css" />
		<script type="text/javascript" src="${pageContext.request.contextPath}/lib/jquery/jquery-1.11.1.js" ></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/lib/bootstrap-3.3.7-dist/js/npm.js" ></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/lib/layer-v3.1.1/layer/layer.js" ></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/lib/bootstrap-3.3.7-dist/js/mylayer.js" ></script>
	</head>
	<body>
			<!--导航栏开始-->
			<nav class="navbar navbar-default">
			  <div class="container">
			    <!-- Brand and toggle get grouped for better mobile display -->
			    <div class="navbar-header">
			      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
			        <span class="sr-only">Toggle navigation</span>
			        <span class="icon-bar"></span>
			        <span class="icon-bar"></span>
			        <span class="icon-bar"></span>
			      </button>
			      <a class="navbar-brand" href="#">教务管理系统</a>
			    </div>
			    <!-- Collect the nav links, forms, and other content for toggling -->
			    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
			      <ul class="nav navbar-nav">
			        <li><a href="${pageContext.request.contextPath}/student?method=pageList"><span class="glyphicon glyphicon-user" aria-hidden="true"></span>&nbsp;&nbsp;&nbsp;&nbsp;学生信息管理</a></li>
			        <li class="active"><a href="${pageContext.request.contextPath}/banji?method=pageList"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp;&nbsp;&nbsp;&nbsp;班级信息管理</a></li>
			         <li><a href="${pageContext.request.contextPath}/course?method=pageList"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>&nbsp;&nbsp;&nbsp;&nbsp;课程信息管理</a></li>
			      </ul>
			      <ul class="nav navbar-nav navbar-right">
			      	<li><a><span aria-hidden="true"></span>欢迎登陆 ：${user.name}</a></li>&nbsp;&nbsp;&nbsp;&nbsp;
			        <li><a href="href="${pageContext.request.contextPath}/login?method=logout"><span class="glyphicon glyphicon-off" aria-hidden="true"></span>&nbsp;&nbsp;&nbsp;&nbsp;注销</a></li>
			        
			      </ul>
			    </div><!-- /.navbar-collapse -->
			  </div><!-- /.container-fluid -->
			</nav>
			<!--导航栏结束-->		
			
			<!--内容开始-->
			<div class="container"><!--留白非全屏-->
				<div class="row">
					<!--左边部分开始-->
					<div class="col-md-2">
						<div class="list-group">
							  <a href="${pageContext.request.contextPath}/banji?method=pageList" class="list-group-item ">
							    班级列表
							  </a>
							  <a href="banji_add.jsp" class="list-group-item active">班级添加</a>
							  <a href="javascript:deleteAll()" class="list-group-item">批量删除</a>
						</div>
					</div>
					<!--左边部分结束-->
					
					<!--右边部分开始-->
						<div class="col-md-10">
							<form action="${pageContext.request.contextPath}/banji?method=insert" method="post">
								<form>
								  <div class="form-group">
								    <label for="banjiname">班级</label>
								    <input type="text" name="name" onblur="checkName()" class="form-control" id="banjiname" placeholder="名称">
								  </div>
								  <div class="form-group">
								    <label for="banjipeople">人数</label>
								    <input type="text" name="people" class="form-control" id="banjipeople" placeholder="人数">
								  </div>
								  <div class="form-group">
								    <label for="banjiteatch">授课老师</label>
								    <input type="text" name="teatch" class="form-control" id="banjiteatch" placeholder="教师">
								  </div>
								  选择课程：
								<select name="courseId">
									<option>--请选择--</option>
									<c:forEach items="${list}" var="course">
										<option value="${course.id}">${course.name}</option>
									</c:forEach>
								</select>
								<br/>
								  
								  <button type="submit" class="btn btn-default">添加</button>&nbsp;&nbsp;&nbsp;&nbsp;
								  <button type="reset" class="btn btn-default">重置</button>
								   <!-- ajax请求，判断姓名是否重名 -->
								 	<script type="text/javascript">
							 		function checkName(){
							 			var name = document.getElementById("banjiname").value;//通过本页面拿到文本框的值
									 	$.post(
									 		"${pageContext.request.contextPath}/banji?method=checkName",  //url,请求服务器端的地址
									 		 {"name":name}, //传给服务器的
									 		 function(data){  //服务器给页面弹出的
									 			 if(data.isExist){
									 				 mylayer.errorAlert("该班级已存在，请重新添加新班级")
									 			 }
									 		 },
									 		 "json"
									 	);
							 		}
							 		</script>
							</form>
						</form>
							
						</div>
					<!--右边部分结束-->
		<script type="text/javascript" src="../lib/jquery/jquery-1.11.1.js" ></script>
		<script type="text/javascript" src="../lib/bootstrap-3.3.7-dist/js/npm.js" ></script>
	</body>
</html>
